
using UnityEngine;


public static class MaterialPropertyUtils
{
    public static void SetColor(Renderer renderer,string name,Color color)
    {
        MaterialPropertyBlock propertyBlock = GetPropertyBlock(renderer);
        propertyBlock.SetColor(name, color);
        renderer.SetPropertyBlock(propertyBlock);
    }

    public static void SetFloat(Renderer renderer,string name,float value)
    {
        MaterialPropertyBlock propertyBlock = GetPropertyBlock(renderer);
        propertyBlock.SetFloat(name, value);
        renderer.SetPropertyBlock(propertyBlock);
    }
    
    public static MaterialPropertyBlock GetPropertyBlock(Renderer renderer)
    {
        MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
        propertyBlock.Clear();
        renderer.GetPropertyBlock(propertyBlock);
        return propertyBlock;
    }

    public static void SetPropertyBlock(Renderer renderer, MaterialPropertyBlock propertyBlock)
    {
        renderer.SetPropertyBlock(propertyBlock);
    }
    
}
